﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using Wolfbyte.Core;
using System.Data.Linq.Mapping;

namespace Wolfbyte.UnitOfWork.LinqToSql
{
    public class DataContextFactory : IFactory<DataContext>
    {
        private MappingSource MappingSource;
        private string FileOrConnectionOrServer;

        public DataContextFactory(string FileOrConnectionOrServer, IFactory<MappingSource> MappingSourceFactory)
        {
            this.FileOrConnectionOrServer = FileOrConnectionOrServer;
            this.MappingSource = MappingSourceFactory.Create();
        }

        #region IFactory<DataContext> Members

        public DataContext Create()
        {
            return new DataContext(FileOrConnectionOrServer, MappingSource);
        }

        #endregion
    }
}
